home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BKISSSRC.ZIP / CREDITS / PALETTE.INC < prev    next >
Encoding:
Text File  |  1994-02-10  |  4.1 KB  |  110 lines

  1. ;fade_out
  2. ;fade_to
  3.  
  4. PALETTE_NUMBER = 256       ;normally 256
  5. ;FadeHandler = offset to procedure to call during fading
  6. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  7. macro       Decrease source
  8.             local @@Done
  9.             cmp source,0
  10.             jz @@Done
  11.             dec source
  12. @@Done:     exitm
  13. endm        Decrease
  14. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  15. ;si = offset to palette
  16. ;cx = number of colors to write
  17. ;al = starting palette register
  18. ;
  19. ;DESTROYS: dx,si,cx
  20. ;
  21. MACRO       SetPalette
  22.             mov     dx,cx
  23.             add     cx,cx
  24.             add     cx,dx
  25.             mov     dx,03c8h
  26.             out     dx,al
  27.             inc     dx
  28.             cld
  29.             rep outsb
  30. ENDM        SetPalette
  31. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  32. ;fades out the palette currently loaded to black
  33. PROC        fade_out
  34.             mov cx,64
  35. @@NextLoop: push cx
  36.             mov cx,PALETTE_NUMBER
  37. @@NextColor:      mov dx,3C7h                   ;\
  38.                   mov al,cl                     ; \ send out the color number
  39.                   dec al                        ; /
  40.                   out dx,al                     ;/
  41.                   mov dx,3C9h                   ;DX = DAC_DATA
  42.                   in al,dx                      ;\
  43.                   Decrease al                   ; > BL = red
  44.                   mov bl,al                     ;/
  45.                   in al,dx                      ;\
  46.                   Decrease al                   ; > BH = green
  47.                   mov bh,al                     ;/
  48.                   in al,dx                      ;\
  49.                   Decrease al                   ; > AH = blue
  50.                   mov ah,al                     ;/
  51.                   mov dx,3C8h                   ;\
  52.                   mov al,cl                     ; \ send out the color number
  53.                   dec al                        ; /
  54.                   out dx,al                     ;/
  55.                   mov dx,3C9h                   ;DX = DAC_DATA
  56.                   mov al,bl                     ;\ send out new red
  57.                   out dx,al                     ;/
  58.                   mov al,bh                     ;\ send out new green
  59.                   out dx,al                     ;/
  60.                   mov al,ah                     ;\ send out new blue
  61.                   out dx,al                     ;/
  62.  
  63.                   dec cx                        ;\ loop until all colors
  64.                   jnz @@NextColor               ;/ are done
  65. call FadeHandler
  66.             pop cx
  67.             dec cx                        ;\ loop until all cycles are done
  68.             jnz @@NextLoop                ;/
  69.             ret                           ;return
  70. ENDP        fade_out
  71. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  72. ;fades from palette1 to palette2
  73. ;
  74. ;           DS:SI ==> palette1 (starting palette) [this is modified]
  75. ;           DS:DI ==> palette2 (desired palette)
  76. proc        fade_to
  77.             ;**** converge the current palette to the desired one ****
  78. @@FadeLoop: push si di
  79.             mov cx,PALETTE_NUMBER*3
  80.             xor bx,bx
  81.             cld
  82. @@NextColor:mov al,[byte ds:di]
  83.             cmp [byte ds:si],al
  84.             jz @@ColorDone
  85.             jb @@Increment
  86. @@Decrement:dec [byte ds:si]
  87.             or bx,1             ;set a flag that we're not perfect yet
  88.             jmp @@ColorDone
  89. @@Increment:inc [byte ds:si]
  90.             or bx,1             ;set a flag that we're not perfect yet
  91. @@ColorDone:inc si
  92.             inc di
  93.             dec cx
  94.             jnz @@NextColor
  95.             pop di si
  96.             cmp bx,0            ;if we're perfect, then quit
  97.             jz @@Done
  98.  
  99.             ;**** load in the new palette ****
  100.             push ds si di
  101.             mov cx,PALETTE_NUMBER
  102.             xor al,al
  103.             SetPalette
  104. call FadeHandler
  105.             pop di si ds
  106.             jmp @@FadeLoop
  107. @@Done:     ret
  108. endp        fade_to
  109. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  110.